home *** CD-ROM | disk | FTP | other *** search
- Path: apccorp.apcc.com!root
- From: nfegan@apcc.com (Noel Fegan)
- Newsgroups: comp.lang.c++
- Subject: Re: How Do I Color A Button?
- Date: Thu, 21 Mar 1996 16:18:35 GMT
- Organization: American Power Conversion
- Message-ID: <4irvip$5m9@apccorp.apcc.com>
- References: <4ik07d$7nj@cliffy.lfwc.lockheed.com>
- NNTP-Posting-Host: hewie.galway.apcc.com
- X-Newsreader: Forte Free Agent 1.0.82
-
- James Bassett <bassett@flash.net> wrote:
-
- >Need to know how to color a button in a dialog box. I have tried using
- >SetBkColor, FillRect and CBrush class but with no results. HELP
-
- > Jim Bassett
-
- From the API functions you mention I am assuming you mean MS Windows. By a
- button I presume you mean pushbuttons. In Windows the term button is s general
- term which covers push buttons, radio buttons and check boxes. I looked into
- this before and I found that you cannot alter the color of a pushbutton.
-
- If you are using Microsoft MFC framework then note that the framework calls the
- function CWnd::OnCtlColor when a child control is about to be drawn.
-
- afx_msg HBRUSH OnCtlColor( CDC* pDC, CWnd* pWnd, UINT nCtlColor );
-
- Most controls send this message to their parent (usually a dialog box) to
- prepare the pDC for drawing the control using the correct colors.
-
- To change the text color, call the SetTextColor member function with the desired
- red, green, and blue (RGB) values.
-
- To change the background color of a single-line edit control, set the brush
- handle in both the CTLCOLOR_EDIT and CTLCOLOR_MSGBOX message codes, and call the
- CDC::SetBkColor function in response to the CTLCOLOR_EDIT code.
-
- Note, however, that the nCtlColor parameter can be CTLCOLOR_BTN, but even if you
- call SetBkColor here for the control it has no effect. The pushbutton always
- remains the color it is set in the "Colors" setting in Control Panel.
-
- There is a way of changing the color of all buttons, by calling the SetSysColors
- function. However, this makes all the buttons in every application this color,
- which is probably not what you want.
-
- IMHO, the only way to color individual pushbuttons' colors is to draw them as
- ownerdraw button and draw them yourself, replicating the way Windows does it,
- except choosing the colors yourself.
-
-
- --
- Noel Fegan
- European Software Development Department
- American Power Conversion
- I don't speak for APC...
- nfegan@apcc.com
-
-